package j2se.ListOrderMap;

import org.apache.commons.collections.map.ListOrderedMap;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * Created by Auto_Wd on 2015/3/10.
 * com.reesechou.j2se.ListOrderMap
 * ListOrderedMap位于commons-collections的jar包里，与普通的map相比，ListOrderedMap的key可保持原有顺序，在某些情况比如做报表的时候，非常实用。
 */
public class Test {
    public static void main(String[] args){
        Map<String,String> map = new HashMap<String, String>();
        map.put("1","test1");
        map.put("2","test2");
        map.put("3","test3");
        map.put("4","test4");
        Set<Map.Entry<String,String>> entrySet = map.entrySet();
        for(Map.Entry entry : entrySet){
            System.out.println(entry.getKey()+": "+entry.getValue());
        }
        Map<String,String> listOrderMap =  ListOrderedMap.decorate(new HashMap());
        listOrderMap.put("1","test1");
        listOrderMap.put("2","test2");
        listOrderMap.put("3","test3");
        listOrderMap.put("4","test4");
        Set<Map.Entry<String, String>> entrySet2 = listOrderMap.entrySet();
        for (Map.Entry<String, String> entry : entrySet2) {
            System.out.println(entry.getKey() + ":" + entry.getValue());
        }
        if(String.class==new String().getClass()){
            System.out.println("====1======");
        }
        if(int.class==new Integer(0).getClass()){
            System.out.println("====2======");
        }
        if(Integer.class==new Integer(0).getClass()){
            System.out.println("====321=1=====");
        }
    }
}
